package com.example.springcloud.controller;

import com.example.api.user.UserApi;
import com.example.springcloud.common.ResponseEntity;
import com.example.springcloud.common.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 莫磊
 * @date 2025/8/21
 * @description
 */
@RestController
@RequestMapping("/feign/user")
public class UserForOpenFeignController {

    @Resource
    private UserApi userApi;

    @GetMapping("/getById/{id}")
    public ResponseEntity<User> getById(@PathVariable("id") Long id) {
        return userApi.getById(id);
    }

    @PostMapping("/addUser")
    public ResponseEntity<User> addUser(User user) {
        return userApi.addUser(user);
    }

    @GetMapping("/findByNameLike/{name}")
    public ResponseEntity<List<User>> findByNameLike(@PathVariable("name") String name) {
        return userApi.findByNameLike(name);
    }
}
